<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src="js/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/page.js"></script>
<script type="text/javascript" src="js/common.js"></script>
<title>评论管理</title>
</head>
<body>
	<jsp:include page="navigation.jsp"></jsp:include>
	<div class="container" style="margin-left: 190px;">
		<div class="topbar-inner">
			<div class="myhead">
				<span class="crumb-name">${ user_name }发出的评论</span>
			</div>
		</div>
		<div class="topbar-inner">
				<div class="search">
					<button type="button" id="search_btn" onclick="goback(${ userid })"
						class="btn btn-default"
						style="margin-left: 20px; margin-top: 1px;">返回</button>
				</div>
			</div>
		<form id="pageForm" action="usercommentinfo" method="post">
			<input type="hidden" value="${ userid }" name="userid" />
			<input type="hidden" value="${ page.pageCount }" id="pageCount"
					name="pageCount" /> <input type="hidden"
					value="${ page.pageIndex }" id="pageIndex" name="pageIndex" />
		</form>
			<div style="margin: 20px 20px 20px 20px; text-align: center;">
				<table class="table table-bordered table-hover table-striped">
					<thead>
						<tr>
							<th>评论内容</th>
							<th>评论时间</th>
							<th>操作</th>
						</tr>
					</thead>
					<tbody>
						<c:forEach items="${ list }" var="l">
							<tr>
								<td><c:if test="${fn:length(l.content) > 25}">${fn:substring(l.content, 0, 23)}...</c:if>
									<c:if test="${fn:length(l.content) <= 25}">${ l.content }</c:if>
								</td>
								<td><fmt:formatDate value="${ l.create_time }" pattern="yyyy-MM-dd HH:mm:ss" type="date" dateStyle="long" /></td>
								<td>
								<c:if test="${ l.is_delete == 1 }">
								已通过
								</c:if>
								<c:if test="${ l.is_delete == 2 }">
								未通过
								</c:if>
								<c:if test="${ l.is_delete == 0 }">
								<a href="javascript:" onclick="toAccess(${ l.id })">通过</a> &emsp;|&emsp; <a href="javascript:" onclick="unAccess(${ l.id })">不通过</a>
								</c:if>
								</td>
							</tr>
						</c:forEach>

					</tbody>
				</table>
				<input type="hidden" value="${ page.pageCount }" id="pageCount" name="pageCount" /> <input type="hidden" value="${ page.pageIndex }" id="pageIndex" name="pageIndex" />
				<c:if test="${ page == null }">
					<div style="font-size: larger;">暂无数据</div>
				</c:if>
				<c:if test="${ page != null && page.pageCount > 1 }">
					<ul id="pagination" class="pagination">

					</ul>
					<script type="text/javascript">
						setPage(document.getElementById("pagination"),
								parseInt($("#pageCount").val()), parseInt($(
										"#pageIndex").val()));
					</script>
				</c:if>
			</div>
	</div>
	<script>
		$(function() {
			$('.submenu_6_2').addClass('submenu_native');
		});

		function toAccess(id) {
			$.ajax({
				type: 'post', 
				data: {comment_id: id, type: 1},
				url: 'commentdelete', 
				success: function(data) {
					if (data.code == 0) {
						alert("操作成功！");
						window.location.reload();
					} else {
						alert(data.message);
					}
				}
			});
		}
		function unAccess(id) {
			$.ajax({
				type: 'post', 
				data: {comment_id: id, type: 2},
				url: 'commentdelete', 
				success: function(data) {
					if (data.code == 0) {
						alert("操作成功！");
						window.location.reload();
					} else {
						alert(data.message);
					}
				}
			});
		}
		function goback(userid) {
			window.location.href = 'userdetail?userid=' + userid;
		}
	</script>
</body>

</html>